<?php
	class UserTest extends PHPUnit_Framework_TestCase
	{
		protected $_user;
		protected $_config;

		protected function setUp() 
		{ 
			$this->_user = new User();
			$this->_config = Zend_Registry::get('config');
		}
		
		protected function tearDown() 
		{ 
			unset($this->_user);
			unset($this->_config);
		}

		public function testDomain()
		{
			$this->assertEquals($this->_user->getDomain(), $this->_config->domain->name->users);
		}
		
		public function testCreateIdentity()
		{
			$this->_user->setAttributes(array(
				'username' => 'unittest',
				'user_type' => 'member',
				'first_name' => 'unit',
				'last_name' => 'test',
				'email' => 'unit@test',
			));

			$this->_user->save();
			$identity = $this->_user->createIdentity();
			
			$this->assertEquals($identity->id, $this->_user->getId());
			$this->assertEquals($identity->username, $this->_user->getAttribute('username'));
			$this->assertEquals($identity->user_type, $this->_user->getAttribute('user_type'));
			$this->assertEquals($identity->first_name, $this->_user->getAttribute('first_name'));
			$this->assertEquals($identity->last_name, $this->_user->getAttribute('last_name'));
			$this->assertEquals($identity->email, $this->_user->getAttribute('email'));

			$this->_user->delete();
		}
	}
